<% layout('/layouts/default.html', {title: '新手任务管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('新手任务管理')}
			</div>

			<div class="box-tools pull-right">
<!--				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>-->
				<% if(hasPermi('pt:ptXinshou:edit')){ %>
					<a href="${ctx}/pt/ptXinshou/form" class="btn btn-default btnTool" title="${text('新增新手任务')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="input"  action="#" method="post" class="form-inline">
			<div class="form-group">
				<label class="control-label">${text('是否开启')}：</label>
				<div class="control-inline">
					<#form:radio id="xinshou_open" name="xinshou_open" value="${xinshou_open}" dictType="sys_yes_no" class="form-control required"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('新手任务期(天)')}：</label>
				<div class="control-inline">
					<#form:input name="xinshou_time" value="${xinshou_time}" maxlength="9" class="form-control width-120" onchange="chufa(this)"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('新手奖励(元)')}：</label>
				<div class="control-inline">
					<#form:input name="xinshou_jine" value="${xinshou_jine}" maxlength="9" class="form-control width-120" onchange="chufa(this)"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">${text('邀请人奖励(元)')}：</label>
				<div class="control-inline">
					<#form:input name="xinshou_parent_jine" value="${xinshou_parent_jine}" maxlength="9" class="form-control width-120" onchange="chufa(this)"/>
				</div>
			</div>
		</#form:form>
	</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ptXinshou}" action="${ctx}/pt/ptXinshou/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('任务类型')}：</label>
					<div class="control-inline">
						<#form:input path="type" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务数量')}：</label>
					<div class="control-inline">
						<#form:input path="num" maxlength="9" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('视频地址')}：</label>
					<div class="control-inline">
						<#form:input path="url" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务奖励总金额')}：</label>
					<div class="control-inline">
						<#form:input path="jine" maxlength="6" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务名称')}：</label>
					<div class="control-inline">
						<#form:input path="name" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务说明')}：</label>
					<div class="control-inline">
						<#form:input path="beizhu" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否开启 1是 0否')}：</label>
					<div class="control-inline">
						<#form:input path="isOpen" maxlength="2" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('序号')}：</label>
					<div class="control-inline">
						<#form:input path="xuhao" maxlength="2" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm isQuick">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("任务类型")}', name:'type', index:'a.type', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('pt_xinshou_fenlei')}, val, '${text("未知")}', true);
		}},
		{header:'${text("任务数量")}', name:'num', index:'a.num', width:150, align:"center"},
		{header:'${text("视频(图片)地址")}', name:'url', index:'a.url', width:150, align:"left"},
		{header:'${text("任务奖励总金额")}', name:'jine', index:'a.jine', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text("任务名称")}', name:'name', index:'a.name', width:150, align:"left"},
		{header:'${text("任务说明")}', name:'beizhu', index:'a.beizhu', width:150, align:"left"},
		{header:'${text("是否开启")}', name:'isOpen', index:'a.is_open', width:150, align:"left", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '${text("未知")}', true);
		}},
		{header:'${text("序号")}', name:'xuhao', index:'a.xuhao', width:150, align:"center"},
		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
			var actions = [];
			//<% if(hasPermi('pt:ptXinshou:edit')){ %>
				actions.push('<a href="${ctx}/pt/ptXinshou/form?id='+row.id+'" class="btnList" title="${text("编辑新手任务")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				// actions.push('<a href="${ctx}/pt/ptXinshou/delete?id='+row.id+'" class="btnList" title="${text("删除新手任务")}" data-confirm="${text("确认要删除该新手任务吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			//<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
<script>
	function chufa(obj){
		console.log($(obj).val());
		var name = $(obj).attr("name");
		if(name == 'xinshou_time'){
			saveSetting(26,$(obj).val());
		}
		if(name == 'xinshou_jine'){
			saveSetting(27,$(obj).val());
		}
		if(name == 'xinshou_parent_jine'){
			saveSetting(28,$(obj).val());
		}

	}
	$('#xinshou_open').on('ifChecked', function(){
		console.log($('#xinshou_open input:radio:checked').val());
		saveSetting(25,$('#xinshou_open input:radio:checked').val());
	});

	function saveSetting(id,paramValue){
		$.post("${ctx}/pt/ptSetting/save",{id,paramValue},function (res){
			js.showMessage(res.message);
		})
	}

</script>